import 'package:flutter/material.dart';
import './mine_cell.dart';
import '../common.dart';

class MinePage extends StatefulWidget {
  const MinePage({super.key});

  @override
  State<MinePage> createState() => _MinePageState();
}

class _MinePageState extends State<MinePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(
          title: const Text(
            '我的',
            style: TextStyle(
              color: Colors.black,
            ),
          ),
          centerTitle: true,
          backgroundColor: GlobalThemeColor,
          toolbarHeight: 50,
        ),
        body: Container(
          color: const Color.fromARGB(255, 241, 241, 241),
          child: MediaQuery.removePadding(
            removeTop: true,
            context: context,
            child: ListView(
              children: [
                headerWidget(context),
                Column(
                  children: [
                    const SizedBox(
                      height: 10,
                    ),
                    const MineCell(
                      imageName: 'images/wxzf.png',
                      title: '支付',
                    ),
                    const SizedBox(
                      height: 10,
                    ),
                    const MineCell(
                      imageName: 'images/微信收藏.png',
                      title: '收藏',
                    ),
                    Row(
                      children: [
                        Container(
                          width: 50,
                          height: 0.5,
                          color: Colors.white,
                        ),
                        Container(height: 0.5, color: Colors.grey)
                      ],
                    ),
                    const MineCell(
                      imageName: 'images/微信相册.png',
                      title: '相册',
                    ),
                    Row(
                      children: [
                        Container(
                          width: 50,
                          height: 0.5,
                          color: Colors.white,
                        ),
                        Container(height: 0.5, color: Colors.grey)
                      ],
                    ),
                    const MineCell(
                      imageName: 'images/微信卡包.png',
                      title: '卡包',
                    ),
                    Row(
                      children: [
                        Container(
                          width: 50,
                          height: 0.5,
                          color: Colors.white,
                        ),
                        Container(height: 0.5, color: Colors.grey)
                      ],
                    ),
                    const MineCell(
                      imageName: 'images/微信表情.png',
                      title: '表情',
                    ),
                    const SizedBox(height: 10),
                    const MineCell(
                      imageName: 'images/微信设置.png',
                      title: '设置',
                    ),
                  ],
                )
              ],
            ),
          ),
        ));
  }
}

Widget headerWidget(BuildContext context) {
  var text = 'szy';

  return Container(
    height: 110,
    color: const Color.fromARGB(255, 255, 255, 255),
    child: Container(
      margin: const EdgeInsets.all(10),
      child: Row(
        children: [
          Container(
            width: 70,
            height: 70,
            decoration: BoxDecoration(
                borderRadius: BorderRadius.circular(10),
                image: const DecorationImage(
                    image: NetworkImage(
                        'http://gips1.baidu.com/it/u=8355271,1357180122&fm=3028&app=3028&f=JPEG&fmt=auto?w=1280&h=960'),
                    fit: BoxFit.cover)),
          ),
          Container(
            width: screenWidth(context) - 90,
            padding: const EdgeInsets.only(left: 10),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                // 昵称
                SizedBox(
                  height: 45,
                  child: Text(
                    '昵称$text',
                    style: const TextStyle(fontSize: 25, color: Colors.grey),
                  ),
                ),
                // 号码
                const SizedBox(
                  height: 35,
                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      Text(
                        '18694274200',
                        style: TextStyle(fontSize: 17, color: Colors.grey),
                      ),
                      Image(
                        image: NetworkImage(
                            'https://img2.baidu.com/it/u=2505183683,63172993&fm=253&fmt=auto&app=138&f=JPEG?w=500&h=500'),
                        width: 15,
                      )
                    ],
                  ),
                )
              ],
            ),
          )
        ],
      ),
    ),
  );
}

// 获取屏幕宽高
double screenWidth(BuildContext context) {
  return MediaQuery.of(context).size.width;
}
